package me.firstapp.manage.marketing;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import me.firstapp.manage.common.BaseManage;
import me.firstapp.module.weixin.system.Banner;
import me.firstapp.module.weixin.system.Broadcast;
import me.firstapp.service.weixin.system.BannerService;
import me.firstapp.service.weixin.system.BroadcastService;

@Controller
@RequestMapping(value = "/marketingManage")
public class MarketingManagePage extends BaseManage {

	@Autowired
	private BannerService bannerService;

	@Autowired
	private BroadcastService broadcastService;

	@RequestMapping(value = "/bannerList.html", method = RequestMethod.GET)
	public ModelAndView bannerListView(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
		return new ModelAndView("marketing/bannerList", modelMap);
	}

	@RequestMapping(value = "/bannerAdd.html", method = RequestMethod.GET)
	public ModelAndView bannerAddView(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
		return new ModelAndView("marketing/bannerAdd", modelMap);
	}

	@RequestMapping(value = "/bannerUpdate.html", method = RequestMethod.GET)
	public ModelAndView bannerUpdateView(Long id, HttpServletRequest request, HttpServletResponse response,
			ModelMap modelMap) {
		Banner banner = bannerService.findById(id);
		modelMap.put("banner", banner);
		modelMap.put("id", id);
		return new ModelAndView("marketing/bannerUpdate", modelMap);
	}

	@RequestMapping(value = "/broadcastList.html", method = RequestMethod.GET)
	public ModelAndView broadcastListView(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
		return new ModelAndView("marketing/broadcastList", modelMap);
	}

	@RequestMapping(value = "/broadcastAdd.html", method = RequestMethod.GET)
	public ModelAndView broadcastAddView(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
		return new ModelAndView("marketing/broadcastAdd", modelMap);
	}

	@RequestMapping(value = "/broadcastUpdate.html", method = RequestMethod.GET)
	public ModelAndView broadcastUpdateView(Long id, HttpServletRequest request, HttpServletResponse response,
			ModelMap modelMap) {
		Broadcast broadcast = broadcastService.findById(id);
		modelMap.put("broadcast", broadcast);
		modelMap.put("id", id);
		return new ModelAndView("marketing/broadcastUpdate", modelMap);
	}
}
